package org.neuedu.ssmp.crm.controller;


import org.junit.Test;
import org.neuedu.ssmp.crm.entity.Menuitem;
import org.neuedu.ssmp.crm.entity.SysRoleAuthor;
import org.neuedu.ssmp.crm.service.IMenuitemService;
import org.neuedu.ssmp.crm.service.ISysRoleAuthorService;
import org.neuedu.ssmp.crm.util.MenuTreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author MoonHolder
 * @since 2019-12-09
 */
@RestController
@RequestMapping("/menuitem")
public class MenuitemController {

    @Autowired
    private ISysRoleAuthorService service;

    @GetMapping("show")
    @Test
    public List<SysRoleAuthor> menu(@RequestParam Integer id){
        List<SysRoleAuthor> protoList = service.list(id);
        MenuTreeUtil menuTreeUtil = new MenuTreeUtil();
        protoList.forEach(System.out::println);
        return menuTreeUtil.getMenuTree(protoList);
    }
}
